home *** CD-ROM | disk | FTP | other *** search
/ CD Actual Thematic 7: Programming / CDAT7.iso / demos / VisualAge for Java 2.0 Entry / setup / data1.cab / ide-e / IDE / cache / 11FGS8I (.txt) < prev    next >
Encoding:
Java Class File  |  1998-09-16  |  3.0 KB  |  83 lines

  1. package com.sun.java.swing.plaf.metal;
  2.  
  3. import com.sun.java.swing.ButtonModel;
  4. import com.sun.java.swing.Icon;
  5. import com.sun.java.swing.JButton;
  6. import com.sun.java.swing.plaf.UIResource;
  7. import java.awt.Color;
  8. import java.awt.Component;
  9. import java.awt.Graphics;
  10. import java.io.Serializable;
  11.  
  12. class MetalIconFactory$InternalFrameAltMaximizeIcon implements Icon, UIResource, Serializable {
  13.    JButton parentButton;
  14.    ButtonModel buttonModel;
  15.    Color backgroundColor;
  16.    Color titleColor;
  17.    Color titleHighlight;
  18.    Color edgeColor;
  19.    Color smallEdgeColor;
  20.    Color downRightHighlight;
  21.    Color upLeftHighlight;
  22.    int iconSize = 12;
  23.  
  24.    public MetalIconFactory$InternalFrameAltMaximizeIcon(int size) {
  25.       this.iconSize = size;
  26.    }
  27.  
  28.    public void paintIcon(Component c, Graphics g, int x, int y) {
  29.       this.parentButton = (JButton)c;
  30.       this.buttonModel = this.parentButton.getModel();
  31.       this.downRightHighlight = MetalLookAndFeel.getPrimaryControlHighlight();
  32.       this.upLeftHighlight = MetalLookAndFeel.getPrimaryControlShadow();
  33.       this.backgroundColor = MetalLookAndFeel.getPrimaryControl();
  34.       this.titleColor = MetalLookAndFeel.getPrimaryControlShadow();
  35.       this.titleHighlight = MetalLookAndFeel.getPrimaryControlDarkShadow();
  36.       this.edgeColor = MetalLookAndFeel.getPrimaryControlShadow();
  37.       this.smallEdgeColor = MetalLookAndFeel.getPrimaryControlInfo();
  38.       if (this.parentButton.getClientProperty("paintActive") != Boolean.TRUE) {
  39.          this.downRightHighlight = MetalLookAndFeel.getControlHighlight();
  40.          this.upLeftHighlight = MetalLookAndFeel.getControlShadow();
  41.          this.backgroundColor = MetalLookAndFeel.getControl();
  42.          this.titleColor = MetalLookAndFeel.getControlShadow();
  43.          this.titleHighlight = MetalLookAndFeel.getControlDarkShadow();
  44.          this.edgeColor = MetalLookAndFeel.getControlShadow();
  45.       } else if (this.buttonModel.isPressed() && this.buttonModel.isArmed()) {
  46.          this.backgroundColor = MetalLookAndFeel.getPrimaryControlShadow();
  47.          this.titleColor = MetalLookAndFeel.getPrimaryControlDarkShadow();
  48.          this.titleHighlight = MetalLookAndFeel.getPrimaryControlInfo();
  49.          this.edgeColor = MetalLookAndFeel.getPrimaryControlDarkShadow();
  50.       }
  51.  
  52.       int oneThird = this.iconSize / 3;
  53.       int halfSize = this.iconSize / 2;
  54.       g.translate(x, y);
  55.       g.setColor(this.backgroundColor);
  56.       g.fillRect(0, 0, this.iconSize, this.iconSize);
  57.       g.setColor(this.downRightHighlight);
  58.       g.drawLine(1, this.iconSize - 1, this.iconSize - 1, this.iconSize - 1);
  59.       g.drawLine(this.iconSize - 1, 1, this.iconSize - 1, this.iconSize - 1);
  60.       g.setColor(this.upLeftHighlight);
  61.       g.drawLine(0, 0, 0, this.iconSize - 2);
  62.       g.drawLine(0, 0, this.iconSize - 2, 0);
  63.       g.setColor(this.edgeColor);
  64.       g.drawRect(1, 1, this.iconSize - 3, this.iconSize - 3);
  65.       g.setColor(this.smallEdgeColor);
  66.       g.drawRect(1, oneThird, halfSize, halfSize);
  67.       g.setColor(this.titleColor);
  68.       g.fillRect(2, oneThird + 1, halfSize - 1, halfSize - oneThird);
  69.       g.setColor(this.titleHighlight);
  70.       g.drawLine(2, halfSize + 1, oneThird, halfSize + 1);
  71.       g.drawLine(oneThird + 1, halfSize, halfSize, halfSize);
  72.       g.translate(-x, -y);
  73.    }
  74.  
  75.    public int getIconWidth() {
  76.       return this.iconSize;
  77.    }
  78.  
  79.    public int getIconHeight() {
  80.       return this.iconSize;
  81.    }
  82. }
  83.